package com.study.modules.designPatterns.No1SingletonMode;

/**
 * 单例模式：懒汉式
 * 优点：第一次调用才初始化，避免内存浪费
 * 缺点：每次调用都要进行同步，影响性能
 */
public class SingletonLazyMan {
    private static SingletonLazyMan instance;

    private SingletonLazyMan() {
    }

    public static SingletonLazyMan getInstance() {
        synchronized (SingletonLazyMan.class) {
            if (instance == null) {
                instance = new SingletonLazyMan();
            }
            return instance;
        }
    }

}
